// components/switchShop/switchShop.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    value: {
      type: null,
      value: null,
    },
    data: {
      type: Object,
      value: () => {
        return {}
      }
    },
  },
  observers: {
    value(v){
      if(!this.data.data?.list?.length) return
      this.setData({
        insideData: this.data.data?.list?.find(i => i.shop_id === v)
      })
    },
    data(v){
      if(this.data.value && !this.data.insideData.shop_id){
        this.setData({
          insideData: v?.list?.find(i => i.shop_id === this.data.value)
        })
      }
    }
   },
  /**
   * 组件的初始数据
   */
  data: {
    show: false,
    insideData: {},
    pValue: 0,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    openPicker(e) {
      this.setData({
        show: true,
      });
    },
    onClose(){
      this.setData({
        show: false
      })
    },
    getValue(e){
      wx.setStorageSync('shopID', e.detail.value)
      this.triggerEvent("value", {
        type: e.detail.type,
        value: e.detail.value,
      });
      this.onClose()
    },
  }
})